home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / GraphicsWorkshop / Source / Examples / ToTiff / test.m < prev    next >
Encoding:
Text File  |  1991-10-20  |  1.2 KB  |  49 lines

  1. #import <stdio.h>
  2. #import <appkit/graphics.h>
  3. #import <appkit/tiff.h>
  4. #import "NXBitmapImageRepControl.h"
  5. #import "tiff.h"
  6. #import "ControlLoader.h"
  7.  
  8. void main(int argc, char *argv[]) 
  9. {
  10.     id            images;
  11.     id            curImage;
  12.     id            curConvert;
  13.     int            x;
  14.     char            newName[100];
  15.     int            compress = NX_TIFF_COMPRESSION_JPEG;
  16.     float            factor = 10.0;
  17.     BOOL        removeIt = NO;
  18.     
  19.     images = [[[ControlLoader loadControl: "Bitmap"] alloc] init];
  20.  
  21.     for (x = 1; x < argc; x++) {
  22.         if (argv[x][0] == '-') {
  23.             switch (argv[x][1]) {
  24.                 case 'r':    removeIt = YES;
  25.                         break;
  26.                 default:    fprintf(stderr, "Unknown option: %c\n", argv[x][1]);
  27.                         break;
  28.             }
  29.             continue;
  30.         }
  31.         curImage = [images openAndReturnImage: argv[x]];
  32.         strcpy(newName, argv[x]);
  33.         newName[strlen(newName) - 4] = '\0'; 
  34.         strcat(newName, ".tiff");
  35.         [images handleLink: "tiff"];
  36.         curConvert = [images getCurrentConverter];
  37.         [curConvert     setCustomParameter:     TIFF_COMPRESS_METHOD 
  38.                     withValue:             &compress];
  39.         [curConvert     setCustomParameter:     TIFF_COMPRESS_RATIO 
  40.                     withValue:             &factor];
  41.         if ([images saveImage: curImage toFile: newName] && removeIt) {
  42.             remove(argv[x]);
  43.         }
  44.         [curImage free];
  45.     }
  46.  
  47.     [images free];
  48. }
  49.